﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Hack.Xml.Helpers
{
    public static class Fixer
    {
        /// <summary>
        /// Before:
        /// <ParentNode>
        ///    <ChildItem TestAttribute="ValueCasing" >
        /// 	This text Will not Be Harmed!
        ///    </ChildItem>
        /// </ParentNode>
        /// 
        /// After:
        /// <parentnode>
        ///   <childitem testattribute="valuecasing" >
        ///  	This text Will not Be Harmed!
        ///   </childitem>
        /// </parentnode>
        /// 
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static string LowerCaseTags(string xml)
        {
            return Regex.Replace(
                xml,
                @"<[^<>]+>",
                m => { return m.Value.ToLower(); },
                RegexOptions.Multiline | RegexOptions.Singleline);
        }
    }
}
